import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/20 9:00
 * @description TreeMap
 */
public class Solution2 {
    public static void main(String[] args) {

    }
    public int[] findRightInterval(int[][] intervals) {
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < intervals.length; i++) {
            map.put(intervals[i][0], i);
        }
        int[] ret = new int[intervals.length];
        for (int i = 0; i < intervals.length; i++) {
            Map.Entry<Integer, Integer> index = map.ceilingEntry(intervals[i][1]);
            if (index != null) {
                ret[i] = index.getValue();
            } else {
                ret[i] = -1;
            }
        }
        return ret;
    }
}
